var mongoose = require('mongoose');

var date = new Date();

var SiteSchema = new mongoose.Schema({
    name:String,
    url : String,
    order_sort:Number,
    tags : String,
    description:String,
    site_type : { type : mongoose.Schema.Types.ObjectId, ref: 'SiteType' },
    is_show:Number,
    type_id:String,
    create_time:{
        type:Number,
        default:date.getTime()
    },
    update_time:{
        type:Number,
        default:date.getTime()
    }
});


SiteSchema.pre('save',function(next){
    if(this.isNew){
        this.create_time = this.update_time = date.getTime();
    }else{
        this.update_time = date.getTime();
    }

    next();
});

module.exports = SiteSchema;